// SimNet is a Second Life(tm) sim mangement tool that was designed for Fermi Sandbox
// Copyright (C) 2011 Arthur Fermi
// 
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To receive a copy of this license please visit http://www.gnu.org/licenses/

// SimNet - Relay

// Enter the URL to your SimNet system, make sure to include the last /
// This will likely be http://<my-domain.com>/simnet/
string  gstrURL = "http://yourwebsite/simnet/";   

// Enter in the relay link channel, it is used in a whisper to communicate to the prim on the other sim.
integer gintRelay = -23456;   // Relay comms

// Do not change anything below here or you will likely break something
string  gstrHTTP;
integer gintParcelComm1;  // Comm Channel used by SimNet

default
{
    state_entry()
    {
        gstrHTTP = llHTTPRequest(gstrURL + "simnet_toolbar.cn",[HTTP_METHOD, "POST"], ""); 
    }

    listen(integer channel, string name, key id, string message)
    {
        if (channel == gintParcelComm1)
        {
            llWhisper(gintRelay, message);
        }
        else if (channel == gintRelay)
        {
            llRegionSay(gintParcelComm1, message);
        }
    }

    http_response(key request_id, integer status, list metadata, string body)
    {
        if (request_id == gstrHTTP)
        {
            // get Variable to build the string
            gintParcelComm1 =  (integer)body;  
 
            // Link Listens
            llListen(gintRelay, "", NULL_KEY, ""); 
            
            // Device Listens
            gintParcelComm1 = (gintParcelComm1 * 7) / 3;          
            llListen(gintParcelComm1, "", NULL_KEY, "");
       }
    }
}


